#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by PyCharm.
# @Project: Code_Clone_Detection_Educoder
# @File: get_class_result.py
# @Description: 
# @Time: 2018/12/13 10:38
# @Author: ljz

from CCDetector.utils.mysql_pool import mysql_operator


def run(query_id):
    result = mysql_operator.select_all("""
    select user_id, file_path, target_user_id, target_file_path, rate from educoder_code_clone.result 
    where query_id='{}'
    """.format(query_id))
    user_lists = []
    for i in result:
        single_record = {'user_id': i[0],
                         'target_user_id': i[2],
                         'path': {'origin': i[1],
                                  'target': i[3]},
                         'rate': i[4]}
        user_lists.append(single_record)

    return user_lists
